import 'package:flutter/material.dart';

void main() => runApp(MyApp());

/// 底部弹出用于提示用户，一会消失
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SnackBar',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        splashColor: Colors.transparent,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SnackBar'),
      ),
      body: Center(
        child: TextButton(
          child: Text('show snackbar'),
          onPressed: () => Scaffold.of(context).showSnackBar(SnackBar(
            content: Text('删除中...'),
            action: SnackBarAction(
              label: "撤销",
              onPressed: () => print('取消撤销'),
            ),
          )),
        ),
      ),
    );
  }
}
